from main_menu import main_menu

class mediator_fake :
    def __init__ ( self ) :
        self . _call_history = [ ]
        self . _hide_menu = False
        self . _configure_title_text_for_menu = None
        self . _configure_next_row_for_menu = [ ]
        self . _localization_main_menu_title = None
        self . _localization_main_menu_create = None
        self . _localization_main_menu_open = None
        self . _localization_main_menu_rename = None
        self . _localization_main_menu_copy = None
        self . _localization_main_menu_quit = None
    def show_menu ( self ) :
        self . _call_history += [ mediator_fake . show_menu ]
    def hide_menu ( self ) :
        self . _hide_menu = True
    def configure_title_text_for_menu ( self , title_text ) :
        self . _call_history += [ mediator_fake . configure_title_text_for_menu ]
        self . _configure_title_text_for_menu = title_text
    def configure_next_row_for_menu ( self , row_text , row_callback ) :
        self . _call_history += [ mediator_fake . configure_next_row_for_menu ]
        self . _configure_next_row_for_menu += [ [ row_text , row_callback ] ]
    def on_main_menu_create ( self ) :
        pass
    def on_main_menu_open ( self ) :
        pass
    def on_main_menu_rename ( self ) :
        pass
    def on_main_menu_copy ( self ) :
        pass
    def on_main_menu_quit ( self ) :
        pass
    def localization_main_menu_title ( self ) :
        return self . _localization_main_menu_title
    def localization_main_menu_create ( self ) :
        return self . _localization_main_menu_create
    def localization_main_menu_open ( self ) :
        return self . _localization_main_menu_open
    def localization_main_menu_rename ( self ) :
        return self . _localization_main_menu_rename
    def localization_main_menu_copy ( self ) :
        return self . _localization_main_menu_copy
    def localization_main_menu_quit ( self ) :
        return self . _localization_main_menu_quit

class main_menu_tests :
    'main_menu'
    def __init__ ( self , test ) :
        self . _test = test
        self . _mediator = mediator_fake ( )
        self . _main_menu = main_menu ( self . _mediator )
    #
    # show_main_menu
    #
    def test_show_main_menu_show_menu ( self ) :
        self . _main_menu . show_main_menu ( )
        self . _test . assume_equal ( self . _mediator . _call_history [ - 1 : ] , [ mediator_fake . show_menu ] )
    def test_show_main_menu_configure_title_text_for_menu ( self ) :
        self . _mediator . _localization_main_menu_title = 'my title'
        self . _main_menu . show_main_menu ( )
        self . _test . assume_equal ( self . _mediator . _configure_title_text_for_menu , 'my title' )
    def test_show_main_menu_configure_next_row_for_menu ( self ) :
        self . _mediator . _localization_main_menu_create = 'my create'
        self . _mediator . _localization_main_menu_open = 'my open'
        self . _mediator . _localization_main_menu_rename = 'my rename'
        self . _mediator . _localization_main_menu_copy = 'my copy'
        self . _mediator . _localization_main_menu_quit = 'my quit'
        self . _main_menu . show_main_menu ( )
        self . _test . assume_equal ( self . _mediator . _configure_next_row_for_menu ,
            [ [ 'my create' , self . _mediator . on_main_menu_create ]
            , [ 'my open' , self . _mediator . on_main_menu_open ]
            , [ 'my rename' , self . _mediator . on_main_menu_rename ]
            , [ 'my copy' , self . _mediator . on_main_menu_copy ]
            , [ 'my quit' , self . _mediator . on_main_menu_quit ]
            ] )
    #
    # hide_main_menu
    #
    def test_hide_main_menu_hide_menu ( self ) :
        self . _main_menu . hide_main_menu ( )
        self . _test . assume_true ( self . _mediator . _hide_menu )
